/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.Entity.SIS;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author user12
 */
@Entity
@Table(name = "SIS_SECTION_TIMES")
@NamedQueries({
    @NamedQuery(name = "SectionTime.findAll", query = "SELECT s FROM SectionTime s"),
    @NamedQuery(name = "SectionTime.findBySemester", query = "SELECT s FROM SectionTime s WHERE s.sectionTimePK.semester = :semester"),
    @NamedQuery(name = "SectionTime.findByCampusNo", query = "SELECT s FROM SectionTime s WHERE s.sectionTimePK.campusNo = :campusNo"),
    @NamedQuery(name = "SectionTime.findByCourseNo", query = "SELECT s FROM SectionTime s WHERE s.sectionTimePK.courseNo = :courseNo"),
    @NamedQuery(name = "SectionTime.findByCourseEdition", query = "SELECT s FROM SectionTime s WHERE s.sectionTimePK.courseEdition = :courseEdition"),
    @NamedQuery(name = "SectionTime.findByActivityCode", query = "SELECT s FROM SectionTime s WHERE s.sectionTimePK.activityCode = :activityCode"),
    @NamedQuery(name = "SectionTime.findBySection", query = "SELECT s FROM SectionTime s WHERE s.sectionTimePK.section = :section"),
    @NamedQuery(name = "SectionTime.findByDayCode", query = "SELECT s FROM SectionTime s WHERE s.sectionTimePK.dayCode = :dayCode"),
    @NamedQuery(name = "SectionTime.findByTimeCode", query = "SELECT s FROM SectionTime s WHERE s.sectionTimePK.timeCode = :timeCode"),
    @NamedQuery(name = "SectionTime.findByEntryDate", query = "SELECT s FROM SectionTime s WHERE s.entryDate = :entryDate"),
    @NamedQuery(name = "SectionTime.findByTerminal", query = "SELECT s FROM SectionTime s WHERE s.terminal = :terminal"),
    @NamedQuery(name = "SectionTime.findByOsUser", query = "SELECT s FROM SectionTime s WHERE s.osUser = :osUser")})
public class SectionTime implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SectionTimePK sectionTimePK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ENTRY_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date entryDate;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    private String terminal;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "OS_USER")
    private String osUser;
    @JoinColumns({
        @JoinColumn(name = "SEMESTER", referencedColumnName = "SEMESTER", insertable = false, updatable = false),
        @JoinColumn(name = "CAMPUS_NO", referencedColumnName = "CAMPUS_NO", insertable = false, updatable = false),
        @JoinColumn(name = "COURSE_NO", referencedColumnName = "COURSE_NO", insertable = false, updatable = false),
        @JoinColumn(name = "COURSE_EDITION", referencedColumnName = "COURSE_EDITION", insertable = false, updatable = false),
        @JoinColumn(name = "ACTIVITY_CODE", referencedColumnName = "ACTIVITY_CODE", insertable = false, updatable = false),
        @JoinColumn(name = "SECTION", referencedColumnName = "SECTION", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Timetable timetable;
    @JoinColumn(name = "TIME_CODE", referencedColumnName = "TIME_CODE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Time time;

    public SectionTime() {
    }

    public SectionTime(SectionTimePK sectionTimePK) {
        this.sectionTimePK = sectionTimePK;
    }

    public SectionTime(SectionTimePK sisSectionTimesPK, Date entryDate, String terminal, String osUser) {
        this.sectionTimePK = sisSectionTimesPK;
        this.entryDate = entryDate;
        this.terminal = terminal;
        this.osUser = osUser;
    }

    public SectionTime(int semester, short campusNo, short courseNo, short courseEdition, short activityCode, short section, short dayCode, short timeCode) {
        this.sectionTimePK = new SectionTimePK(semester, campusNo, courseNo, courseEdition, activityCode, section, dayCode, timeCode);
    }

    public SectionTimePK getSisSectionTimesPK() {
        return sectionTimePK;
    }

    public void setSisSectionTimesPK(SectionTimePK sectionTimePK) {
        this.sectionTimePK = sectionTimePK;
    }

    public Date getEntryDate() {
        return entryDate;
    }

    public void setEntryDate(Date entryDate) {
        this.entryDate = entryDate;
    }

    public String getTerminal() {
        return terminal;
    }

    public void setTerminal(String terminal) {
        this.terminal = terminal;
    }

    public String getOsUser() {
        return osUser;
    }

    public void setOsUser(String osUser) {
        this.osUser = osUser;
    }

    public Timetable getSisTimetable() {
        return timetable;
    }

    public void setSisTimetable(Timetable timetable) {
        this.timetable = timetable;
    }

    public Time getSisTimes() {
        return time;
    }

    public void setSisTimes(Time time) {
        this.time = time;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sectionTimePK != null ? sectionTimePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SectionTime)) {
            return false;
        }
        SectionTime other = (SectionTime) object;
        if ((this.sectionTimePK == null && other.sectionTimePK != null) || (this.sectionTimePK != null && !this.sectionTimePK.equals(other.sectionTimePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.SisSectionTimes[ sisSectionTimesPK=" + sectionTimePK + " ]";
    }
    
}
